package com.springcloud.auth.modular.auth.controller;

import com.springcloud.auth.config.OauthConfig;
import com.springcloud.auth.modular.auth.service.TestService;
import com.springcloud.auth.utils.JedisUtil;
import com.springcloud.commom.api.R;
import com.springcloud.minio.feign.IMinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Set;

@RequestMapping("test")
@RestController
@Slf4j
public class TestController {

    @Autowired
    private TestService testService;

    @Autowired
    private JedisUtil jedisUtil;

    @Autowired
    IMinioClient minioClient;

    @RequestMapping("say")
    public R say(String name) throws Exception{
        log.info("TestController===============name:[{}]========",name);

        testService.say();
        return R.success();
    }

    @RequestMapping("test")
    public R test(){
        Set<String> keys = jedisUtil.getKeys(OauthConfig.AUTH_ACCESS_TOKEN + "*");


        return R.data(keys);
    }

    @RequestMapping("test2")
    public String test2(){


        return "哈哈哈";
    }

    @RequestMapping("getUrl")
    public R getUrl(String fileName){
        return minioClient.getUrl(fileName);
    }

    @RequestMapping("upload")
    public R upload(MultipartFile file){
        return minioClient.upload(file);
    }

}
